<template>
  <div id="app">
    <div class="content">
      <router-view></router-view>
    </div>

    <div class="footer">
      <div
        class="footer-item"
        :style="{ color: $route.path === '/home' ? 'red' : '' }"
        @click="toPage('/home')"
      >
        <van-icon name="guide-o" />
        <span>精选</span>
      </div>
      <div
        class="footer-item"
        :style="{ color: $route.path === '/classify' ? 'red' : '' }"
        @click="toPage('/classify')"
      >
        <van-icon name="apps-o" />
        <span>分类</span>
      </div>
      <div
        class="footer-item"
        :style="{ color: $route.path === '/shopCar' ? 'red' : '' }"
        @click="toPage('/shopCar')"
      >
        <van-icon name="shopping-cart-o" />
        <span>购物车</span>
      </div>
      <div
        class="footer-item"
        :style="{ color: $route.path === '/myself' ? 'red' : '' }"
        @click="toPage('/myself')"
      >
        <van-icon name="friends-o" />
        <span>我的</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "App",
  components: {},
  methods: {
    toPage(path) {
      if (this.$route.path === path) {
        return;
      }

      this.$router.push({
        path: path,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
#app {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  // padding-bottom: 50px;

  .content {
    flex: 1;
    overflow: auto;
  }

  .footer {
    display: flex;
    justify-content: space-between;
    width: 100%;
    height: 50px;
    // position: absolute;
    // left: 0;
    // bottom: 0;
    border-top: 1px solid #ddd;
    box-sizing: border-box;

    .footer-item {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      font-size: 12px;

      .van-icon {
        font-size: 24px;
      }
    }
  }
}
</style>
